user_list = [
    {"name": "user1", "unread": 0, "status": "online"},
    {"name": "user2", "unread": 1, "status": "online"},
    {"name": "user3", "unread": 0, "status": "offline"},
    {"name": "user4", "unread": 5, "status": "offline"},
]

user_list.sort(key=lambda x: (x["unread"], x["status"] == "online"), reverse=True)

print(user_list)
